/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MODEL.DAO;
import MODEL.POJO.*;
import java.util.*;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
/**
 *
 * @author samph
 */
public class CustomizequizsDaoSam {
      public static List<Customizequizs> LayDanhSachKetQua(){
        List<Customizequizs> ds = null; 
        //Session session = HibernateUtil.getSessionFactory().openSession();
        Session session = (Session) HibernateUtil.getSessionFactory().openSession();
        try { 
            String hql = "select kq from Customizequizs kq"; 
            Query query = session.createQuery(hql); 
            ds = query.list(); 
        } catch (HibernateException ex) { 
            System.err.println(ex); 
        } finally { 
           //session.close(); 
        } 
        return ds; 
    }
      public static boolean capNhatCustomizequizs(Customizequizs cus) {
        Session session = HibernateUtil.getSessionFactory().openSession();
        
        Transaction transaction = null;
        try {
            transaction = session.beginTransaction();
            session.update(cus);
            transaction.commit();
        } catch (HibernateException ex) {
            //Log the exception
            transaction.rollback();
            System.err.println(ex);
        } finally {
            session.close();
        }
        return true;
    }
      
}
